package com.zodiac.alioth.web.security.auth;

import lombok.Data;

/**
 * Created by well on 15/10/15.
 *
 * @author well
 */
@Data
public class AuthUser implements java.io.Serializable {

    private static final ThreadLocal<AuthUser> AUTH_HOLDER = new ThreadLocal<>();

    private Long uid;
    private String userId;
    private String xToken;
    private String[] roles;
    private String loginName;
    private String userName;
    private String mobile;

    private String code;

    /**
     * token生成时间
     */
    private long tokenCreateTime;

    /**
     * token过期时间
     */
    private long tokenExpireTime;


    public static AuthUser getCurrentUser() {
        return AUTH_HOLDER.get();
    }

    public static void setCurrentUser(AuthUser buyer) {
        AUTH_HOLDER.set(buyer);
    }

    public static void cleanThreadLocal() {
        AUTH_HOLDER.remove();
    }


    /**
     * 创建匿名用户。
     */
    public AuthUser() {

    }

}
